package org.sy.lab.多线程基础._2_同步._2_ReentrantLock._4_使用条件;


public class Main {

	//酒吧里有100瓶老酒，吧台有3个位置，1次只能喝1瓶
	//1个酒保把老酒拿到吧台
	//5个酒鬼在吧台抢酒喝
	public static void main(String[] args) {
		
		Bar bar = new Bar();
		Counter counter = new Counter();
		Bartender bartender = new Bartender(bar, counter);
		Drunkard drunkard = new Drunkard(counter);
		
		Thread thread = new Thread(bartender, "酒保");
		thread.start();
		
		for (int i = 1; i <= 5; i++) {
			Thread thread1 = new Thread(drunkard, "酒鬼" + i);
			thread1.start();
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
